<template>
  <div class="verify">
    <c-section title="门店建设基本信息">
      <template v-slot:right>
        <c-abnormal-preview path="/storeConstruction/exceptionManage" :query="{ constCode: detail.constCode, functionModel: 'SHOP_DECORATION' }" />
      </template>
      <c-list :column="3">
        <c-list-item label="门店编码" :value="detail.shopCode" />
        <c-list-item label="门店" :value="detail.shopName" />
        <c-list-item label="所属客户编码" :value="detail.clientCode" />
        <c-list-item label="所属客户" :value="detail.clientName" />
        <c-list-item label="所属办事处" :value="detail.officeName" />
        <c-list-item label="门店类型" dict-type-code="SHOP_TYPE" :value="detail.shopType" />
        <c-list-item label="门店业务类型" dict-type-code="BIZ_TYPE" :value="detail.shopBizType" />
        <c-list-item label="门店城市级别" dict-type-code="CITY_LEVEL" :value="detail.shopCityLevel" />
        <c-list-item label="门店详细地址" :value="detail.shopAddress" :span="3" />
        <c-list-item label="门店建设项目号" :value="detail.constCode" />
        <c-list-item label="报图类型" dict-type-code="MARKET_TYPE" :value="detail.marketType" />
        <c-list-item label="门店建设类型" dict-type-code="CONST_TYPE" :value="detail.constType" />
        <c-list-item label="商家类别" dict-type-code="BIZMAN_TYPE" :value="detail.bizmanType" />
        <c-list-item label="装修形式" dict-type-code="DECORATION_FORM" :value="detail.decorationFormCal || detail.decorationForm" />
        <c-list-item label="门店建设范围" dict-type-code="DECORATION_RANGE" :value="detail.decorationRange" />
      </c-list>
    </c-section>
    <c-section title="验收数据">
      <c-list ref="form" :model="formData" :rules="formRules" :column="3" label-width="120px">
        <c-list-item label="预计报验申请时间" :value="detail.expectInspectionTime" />
        <c-list-item label="验收类型" dict-type-code="ACCEPT_TYPE" :value="detail.acceptType" />
        <c-list-item label="报验申请人" :value="detail.applyInformantName" />
        <c-list-item label="工程监理" :value="detail.proSupervisorName" />
        <c-list-item label="形象督导" :value="detail.formSupervisorName" />
        <c-list-item label="实际报验申请时间" :value="detail.actualInspectionTime" />
        <c-list-item label="是否验收" dict-type-code="BOOLEANS" :value="detail.isAccept" />
        <c-list-item label="不验收原因" :value="detail.unacceptReason" :span="3" />
        <c-list-item label="验收资料审核结果" zero="不通过" one="通过" :value="detail.acceptReviewResult" />
        <c-list-item label="验收资料审核意见" :value="detail.acceptReviewAdvice" :span="3" />
        <c-list-item label="实际验收时间" :value="detail.actualAcceptTime" />
        <c-list-item label="验收项目专员" :value="detail.accepterName" />
        <c-list-item label="验收进度" dict-type-code="DECORATION_SCHEDULE" :value="detail.acceptSchedule" />
        <c-list-item label="结案类型">
          <c-dict-select v-model="formData.acceptEndType" dict-type-code="DECORATION_CLOSED_TYPE" />
        </c-list-item>
      </c-list>
    </c-section>
    <RelevanceData :unit-code="detail.constUnitCode" type="HARD" />
    <div class="btn-container">
      <c-button @click="clickCancelHandle">取消</c-button>
      <c-button type="primary" @click="clickConfirmHandle">确认</c-button>
    </div>
  </div>
</template>
<script>
import RelevanceData from './components/relevanceData'
import { getApplyDetail, postdDecorationClosedType } from '@/api/check'
export default {
  name: 'CheckHardVerify',
  components: {
    RelevanceData
  },
  data() {
    return {
      detail: {},
      formData: {
        acceptEndType: ''
      },
      formRules: {
        acceptEndType: [{ required: true, message: '请选择结案类型', trigger: 'change' }]
      }
    }
  },
  created() {
    this.getDetail()
  },
  methods: {
    getDetail() {
      const { id } = this.$route.query
      getApplyDetail(id).then(res => {
        this.detail = res.data
        this.$set(this.formData, 'acceptEndType', this.detail.acceptEndType)
      })
    },
    clickCancelHandle() {
      this.$store.dispatch('views/goFirst')
    },
    clickConfirmHandle() {
      return this.$refs.form.validate().then(() => {
        return postdDecorationClosedType(this.$route.query.id, this.formData.acceptEndType).then(res => {
          this.$message.success('操作成功！')
          this.$store.dispatch('views/goFirst')
        })
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.verify{

}
</style>
